fix: map Athena varbinary correctly in athena2pyarrow - #3413
Merged
Conversation
The membership check used `("binary" or "varbinary")`, which evaluates to
the string "binary" and breaks varbinary casting while accepting substrings.
kukushking
approved these changes
Jul 31, 2026
Collaborator
|
Thanks @hsusul ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature or Bugfix
Detail
athena2pyarrowrejected Athenavarbinaryand incorrectly accepted substrings of"binary"(for example"i") because the membership check used("binary" or "varbinary"), which evaluates to the string"binary".athena2pandasso bothbinaryandvarbinarymap topa.binary(), and invalid substrings raiseUnsupportedType.tests/unit/test_data_types.py.Relates
Summary
athena2pyarrowhad a long-standing operator typo in the binary-type branch. This prevented casting Athenavarbinarycolumns (for example viadtype={"col": "varbinary"}on Parquet writes) and made substring values such as"i"/"n"/"ary"incorrectly resolve topa.binary().Reproduction
No AWS credentials are required.
Root cause
("binary" or "varbinary")is the string"binary", so membership becomes substring membership.Implementation
One-line change in
awswrangler/_data_types.py:matching the existing
athena2pandascontract.Regression tests
tests/unit/test_data_types.py:binary/varbinary(case-insensitive) →pa.binary()"i","n","ary","bin"→UnsupportedTypeathena2pandasstill accepts both binary typesValidation
uv run pytest tests/unit/test_data_types.py -v→ 10 passedupstream/mainbefore the fixuv run pytest tests/unit/test_metadata.py tests/unit/test_session.py tests/unit/test_utils.py tests/unit/test_data_types.py -q→ 30 passedAWS_DEFAULT_REGION=us-east-1 uv run pytest -n 4 tests/unit/test_moto.py -q→ 45 passeduv run ruff format --check .→ passuv run ruff check .→ passuv run mypy --install-types --non-interactive awswrangler/_data_types.py→ passuv run doc8 --ignore-path docs/source/stubs --max-line-length 120 docs/source→ passuv lock --check→ passuv build→ built sdist and wheelgit diff --check→ passAWS integration / credential-dependent tests not run
tests/unit/test_s3_parquet.pyand other live-AWS suites require deployed test infrastructure / credentials (as documented inCONTRIBUTING.md). Errors observed without that environment arebotocorecredential/region failures and are unrelated to this change.Pre-existing local findings (clean
upstream/main)uv run mypy awswranglerreports 20 existing errors in unrelated Ray/OpenSearch/etc. modules on this local toolchain; unchanged by this PR. CI Static Checking remains the authoritative gate.Compatibility
binarycontinue to work.varbinarynow succeed instead of raising.pa.binary()now raiseUnsupportedType(correctness fix).By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.